<?php

namespace app\index\controller;

use app\index\model\Banner as BannerModel;
use think\Controller;
use think\Request;
use app\index\model\CompanyNews as CompanyNewsModel;
use app\index\model\IndustryNews as IndustryNewsModel;

class News extends BaseController
{
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $banner = BannerModel::getBanner('news');
        $action = $request->action();
        $this->assign('banner', $banner);
        $this->assign('action', $action);
    }

    /**
     * 品牌新闻
     */
    public function brand()
    {
        $news = CompanyNewsModel::getNews();
        $this->paginate($news->lastPage(), $news->currentPage());
        $this->assign('news', $news);
        return $this->fetch("news-brand");
    }

    /**
     * 新闻详情
     */
    public function brandDetail($id = 0)
    {
        $news = CompanyNewsModel::getById($id);
        $preId = CompanyNewsModel::getPreId($id);
        $nextId = CompanyNewsModel::getNextId($id);
        $this->assign('preId', $preId);
        $this->assign('nextId', $nextId);
        $this->assign('news', $news);
        return $this->fetch("news-brand-detail");
    }

    /**
     * 行业新闻
     */
    public function industry()
    {
        $news = IndustryNewsModel::getNews();
        $this->paginate($news->lastPage(), $news->currentPage());
        $this->assign('news', $news);
        return $this->fetch("news-industry");
    }

    /**
     * 行业新闻详情
     */
    public function industryDetail($id = 0)
    {
        $news = IndustryNewsModel::getById($id);
        $preId = IndustryNewsModel::getPreId($id);
        $nextId = IndustryNewsModel::getNextId($id);
        $this->assign('preId', $preId);
        $this->assign('nextId', $nextId);
        $this->assign('news', $news);
        return $this->fetch("news-industry-detail");
    }

    /**
     * 明星视频
     */
    public function video()
    {
        return $this->fetch("news-video");
    }


}
